const { UUIDV4, UUID, STRING, TEXT, JSON, TINYINT, Model } = require('sequelize');
const db = require('../../helpers/db');

class AfterSaleRecords extends Model {}

AfterSaleRecords.init(
    {
        id: {
            type: UUID,
            defaultValue: UUIDV4,
            primaryKey: true,
            comment: '商品详情ID'
        },
        afterSale: {
            type: STRING(24),
            comment: '外键，售后编号',
            field: 'after_sale'
        },
        user: {
            type: STRING(36),
            allowNull: false,
            comment: '处理人'
        },
        phone: {
            type: STRING(11),
            allowNull: false,
            comment: '处理人电话'
        },
        dealWay: {
            type: TINYINT(1),
            defaultValue: 0,
            comment: '售后类型，0换货，1退款退货，2仅退款',
            field: 'deal_way'
        },
        reason: {
            type: TEXT,
            comment: '处理原因',
            allowNull: false
        },
        remark: {
            type: STRING(32),
            comment: '备注'
        },
        order: {
            type: STRING(24),
            comment: '外键，订单编号（换货时可用）'
        }
    },
    {
        tableName: 'after_sale_records',
        underscored: true,
        sequelize: db
    }
);

module.exports = AfterSaleRecords;
